package org.jwxa.jwxa4j.parser;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

import org.jsoup.nodes.Element;
import org.jsoup.nodes.TextNode;

public class BuilderConfig {

	public static BuilderConfig defaultConfig = new BuilderConfig();
	
	public static BuilderConfig getDefaultInstance() {
        return defaultConfig;
    }
	
	private Map<Type, TreeBuilder> builderMap = new HashMap<Type, TreeBuilder>();
	
	
	public BuilderConfig() {
		builderMap.put(TextNode.class, new TextNodeBuilder());
		builderMap.put(Element.class, new ElementBuilder());
	}
	
	public TreeBuilder getBuilder(Type type) {
		TreeBuilder builder = builderMap.get(type);
		if(builder == null) {
			builder = new EmptyBuilder();
		}
		return builder;
	}
	
}
